<?php
namespace Www\Controller;
use Spartan\Extend\DbTable;
use Spartan\Lib\Controller;
use Model\Admin\Users;

defined('APP_NAME') or die('404 Not Found');

class Index extends Controller {

    public function index(){


        return $this->fetch();
    }

    public function save(){
        var_dump($this->request->post());
        $result = $this->request->UpFile('file1')
            ->setConfig(['save_path'=>attachPath(),'url_root'=>'/public/'])
            ->saveToFile();
            var_dump($result);

    }

    public function verify(){
        \Spartan\Lib\Image::instance();
    }

    public function tableList(){
        $strAction = $this->request->param('action','list');
        $this->assign('action',$strAction);
        switch ($strAction){
            case 'list':
                $arrResult = DbTable::instance()->tableList();
                if ($arrResult[1] != 1){
                    $this->error($arrResult[0],'');
                }
                $this->assign('list',$arrResult[2]);
                break;
            case 'info':
                $arrResult = DbTable::instance()->tableInfo();
                if ($arrResult[1] != 1){
                    $this->error($arrResult[0],'');
                }
                $this->assign('info',$arrResult[2]);
                break;
            case 'save':
                $arrResult = DbTable::instance()->tableCreate();
                return json($arrResult);
                break;
        }
        return $this->fetch(FRAME_PATH.'Tpl/table_creater.tpl');
    }


    public function tableCreate(){
        $arrInfo = DbTable::instance()->tableCreate();
        var_dump($arrInfo);
    }

}